package com.mouliu.base.syn13;

import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

/**
 * @author mouliu
 * @create 2018-04-07-下午12:32
 */
public class Wangmin implements Delayed {

    private String name;
    //身份证
    private String id;
    //截止时间
    private long enTime;
    //自定义工具类
    private TimeUnit timeUnit = TimeUnit.SECONDS;

    public Wangmin(String name,String id,long endTime){
        this.name = name;
        this.id = id;
        this.enTime = endTime;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
    /**
     * 用来判断是否到了截止时间
     * **/

    @Override
    public long getDelay(TimeUnit unit) {
       return enTime-System.currentTimeMillis();
    }
    /**
     * 相互比较排序用
     * **/
    @Override
    public int compareTo(Delayed o) {
        Wangmin w = (Wangmin) o;
        return this.getDelay(this.timeUnit)-w.getDelay(this.timeUnit)>0?1:0;
    }
}
